#include <QApplication>
#include "window/loginwindow.h"
#include "window/mainwindow.h"

//#define Test 1

#ifndef Test

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    WordMemory::LoginWindow loginWindow;

    // 连接登录成功的信号到主窗口显示
    QObject::connect(&loginWindow, &WordMemory::LoginWindow::loginSuccess, [&]() {
            WordMemory::MainWindow *mainWindow = new WordMemory::MainWindow();
            mainWindow->show();
        });

    loginWindow.show();

    return a.exec();
}

#else

#include <QDebug>
#include "util/serverhelper.h"

int main(int argc, char *argv[])
{
    using namespace WordMemory;

    QApplication a(argc, argv);

    serverhelper->getWord(1, "apple");
    serverhelper->getWord(1, "apple");

    QObject::connect(serverhelper, &ServerHelper::getWordFinished, [&](bool success, const Word &word, const QString &error) {
        qDebug() << success;
        qDebug() << word.toJson();
        qDebug() << error;
    });

    return a.exec();
}

#endif
